<!-- 全国房屋详查数据情况 -->
<template>
    <div class="data">
        <span class="sampleRate" @click="sampleRateClick">各省抽样率</span>
        <div class="data-item">
            <img src="@/assets/images/housing/xcrk.png" alt="">
            <p>全国共 <i v-for="item in totalArr" :key="item">{{ item }}</i> 个<br>省份入库数据</p>
        </div>
        <div class="data-item">
            <div class="data-item-type">详查</div>
            <span>全国抽样率<br><b>{{ rate }}%</b></span>
        </div>
    </div>
    <div ref="popupElement" class="popup-bg" id="map-popup">
        <div class="triangle"></div>
        <div class="popup-head">
            <div class="popup-head-title">各省(直辖市)详查数据抽样率</div>
            <div style="cursor: pointer;" class="popup-head-x" @click="hidePopup"><el-icon><CloseBold /></el-icon></div>
        </div>
        <div class="popup-content">
            <div class="popup-table">
                <SampleRate />
            </div>
        </div>
    </div>
</template>
<script setup>
import { getSamplingRate } from '@/api/housingFacilities.js';
import SampleRate from './SampleRate.vue';
import { onClickOutside } from '@vueuse/core';

const totalArr = ref([]);
const rate = ref('');
// 初始显示面积的抽样率情况
function init() {
    getSamplingRate().then((res) => {
        rate.value = res.data.coverage
        totalArr.value = res.data.provinceNum ? Array.from(String(res.data.provinceNum)) : []
    });
}
// 挂载完成
onMounted(() => {
    // 初始化数据
    init();
    hidePopup()
})
const popupElement = ref()
const sampleRateClick = () => {
    popupElement.value.style.display = 'block';
}
const hidePopup = () => {
    popupElement.value.style.display = 'none';
}
onClickOutside(popupElement, hidePopup)
</script>
<style lang='scss' scoped>
.data {
    display: flex;
    justify-content: space-between;
    margin: 20px 10px;

    &-item {
        width: 210px;
        height: 90px;
        background: url('@/assets/images/housing/xc_total.png');
        background-size: 100% 100%;
        display: flex;
        color: #fff;
        font-size: 14px;
        line-height: 24px;

        img {
            display: block;
            height: 60px;
            margin: 15px 10px;
        }

        p {
            margin-top: 24px;

            i {
                display: inline-block;
                width: 18px;
                height: 25px;
                background: #004C86;
                margin: 0 1px;
                font-family: DS-Digital-Normal, DS-Digital;
                font-weight: 600;
                color: #46FFFF;
                font-size: 28px;
                text-align: center;
            }
        }

        &-type {
            width: 104px;
            height: 59px;
            background: url('@/assets/images/housing/cyl.png');
            background-size: 100% 100%;
            margin: 15px 2px 0 10px;
            text-align: center;
            line-height: 45px;
            color: #A1CBFD;
        }

        span {
            display: block;
            font-size: 16px;
            margin-top: 22px;

            b {
                color: #46FFFF;
            }
        }
    }

    .sampleRate {
        position: absolute;
        top: -55px;
        right: 0;
        color: #46ffff;

        &:hover {
            cursor: pointer;
        }
    }
}

.popup-bg {
    width: 450px;
    height: 300px;
    background: rgba(6, 40, 150, 0.8);
    border-radius: 8px 8px 8px 8px;
    border: 2px solid #0190f9;
    display: flex;
    padding: 17px 15px;
    flex-direction: column;
    position: relative;
    position: absolute;
    left: 465px;
    top: 5%;

    .triangle {
        position: absolute;
        top: 10%;
        left: -10px;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-right: 10px solid #0190f9;
    }

    .popup-head {
        justify-content: center;

        display: flex;
        flex-direction: row;
        font-size: 18px;
        font-family: Source Han Sans CN-Bold, Source Han Sans CN;
        font-weight: bold;
        color: #ffffff;
        line-height: 23px;

        .popup-head-title {
            margin-left: auto;
        }

        .popup-head-x {
            margin-left: auto;
            width: 12px;
            height: 12px;
            color: #e6f4fd;
            opacity: 1;
        }
    }

    .popup-content {
        height: 100%;
        display: flex;
        flex-direction: column;
        font-size: 16px;
        font-family: Source Han Sans CN-Medium, Source Han Sans CN;
        font-weight: 500;
        color: #e6f4fd;
        line-height: 23px;

        .popup-content-title {
            background: #050426;
            border-radius: 0px 0px 0px 0px;
            opacity: 0.5;
            padding: 10px 34px;
            justify-content: space-between;
            display: flex;
            flex-direction: row;
        }

        .popup-table {
            width: 100%;
            height: 100%;
            margin-right: 20px;

            .centered-cell {
                display: flex;
                justify-content: center;
                align-items: center;
                height: 100%;
            }

            .el-table {
                width: 90%;
                max-height: 150px;
                overflow-x: hidden;
                overflow-y: auto;
                z-index: 99;
                position: absolute;
                /* background: linear-gradient(135deg, #00032d 0%, #000c58 50%, #00032d 100%); */
                /* 背景透明 */
                background: rgba(0, 0, 0, 0);

                :deep(tr:hover > td) {
                    background: rgba(71, 90, 219, 0.05) !important;
                }

                // top: 70px;
                // background-color: #00032D;
                /* background: linear-gradient(135deg, #00032d 0%, #000c58 50%, #00032d 100%); */
                :deep(.el-table__header) {
                    background: rgba(5, 4, 38, 0.4);

                    tr {
                        background-color: transparent !important;
                    }

                    th.el-table__cell {
                        background-color: transparent !important;
                    }

                    th.el-table__cell.is-leaf {
                        border-bottom: none;
                    }
                }

                :deep(.el-table__row) {
                    background: rgba(5, 4, 38, 0.4);
                }

                :deep(.el-table__inner-wrapper)::before {
                    display: none;
                }
            }
        }
    }
}

.el-tabs--card>.el-tabs__header .el-tabs__item {
    color: #fff !important;
}

.table {
    width: 420px;
    height: 200px;
    // margin: -55px auto 0;
    text-align: center;

    &-header {
        color: #E6F4FD;
        font-size: 16px;
        display: flex;
        border-bottom: 1px solid #475ADB;
        padding-bottom: 6px;

        span {
            display: block;
            width: calc(100%/3);
        }
    }

    &-data {
        height: 170px;
        overflow: hidden;
        margin-top: 4px;

        &-item {
            display: flex;
            background: rgba(71, 90, 219, .15) !important;
            height: 30px;
            line-height: 30px;
            margin-top: 4px;

            span {
                display: block;
                width: calc(100%/3);
                color: #46FFFF;
                font-size: 16px;

                &:first-child {
                    color: #E6F4FD;
                }
            }
        }
    }
}</style>